<template>
  <div class="user">
    <page-search
      :searchFormConfig="searchFormConfig"
      @resetBtnClick="handleResetClick"
      @handleSearchClick="handleSearchClick"
    >
      用户检索
    </page-search>
    <page-modal
      :modalConfig="modalConfigRef"
      ref="refPageModal"
      :default-info="defaultInfo"
      page-name="user"
      modalName="编辑用户信息"
    ></page-modal>
    <page-content
      :contentTableConfig="contentTableConfig"
      pageName="member"
      ref="pageContentRef"
      @editBtnClick="handleeditClick"
      :Edshow="Edshow"
      ><template #is_member="scope">
        <el-button
          plain
          size="mini"
          :type="scope.row.is_member ? 'success' : 'danger'"
        >
          {{ scope.row.is_member ? '会员' : '非会员' }}
        </el-button>
      </template>
      <template #refill_card="scope">
        {{ scope.row.refill_card ? scope.row.refill_card : '0' }}元
      </template>
      <template #rest_record="scope">
        {{ scope.row.rest_record ? scope.row.rest_record : '0' }}次
      </template>
      <template #classify="scope">
        <el-button plain size="mini" type="success">
          <template v-if="scope.row.classify === 1"> 幼儿园 </template>
          <template v-if="scope.row.classify === 2"> 小学组 </template>
          <template v-if="scope.row.classify === 3"> 中学组 </template>
        </el-button>
      </template>
      <template #avatar_url="scope">
        <el-image
          style="width: 60px; height: 60px"
          :src="scope.row.avatar_url"
          :preview-src-list="[scope.row.avatar_url]"
        />
      </template>
    </page-content>
  </div>
</template>

<script lang="ts">
import { computed, defineComponent, ref } from 'vue'
import PageSearch from '@/components/page-search'
import { searchFormConfig } from './config/search.config'
import { contentTableConfig } from './config/content.config'
import { usePageSearch } from '@/hooks/use-page-search'
import PageContent from '@/components/page-content'
import { modalConfig } from './config/modal.config'
import PageModal from '@/components/page-modal'
import usePageModal from '@/hooks/use-page-modal'
export default defineComponent({
  components: { PageSearch, PageContent, PageModal },
  name: 'user',
  setup() {
    //搜索 与 重置框
    const [pageContentRef, handleSearchClick, handleResetClick] =
      usePageSearch()
    //弹窗的 编辑与新建

    const [refPageModal, defaultInfo, handleNewClick, handleeditClick] =
      usePageModal()
    const Edshow = ref(true)
    const modalConfigRef = computed(() => {
      return modalConfig
    })
    return {
      Edshow,
      searchFormConfig,
      handleSearchClick,
      handleResetClick,
      pageContentRef,
      contentTableConfig,
      modalConfigRef,
      refPageModal,
      defaultInfo,
      handleeditClick,
      modalConfig
    }
  }
})
</script>

<style scoped></style>
